import Vuex from "vuex";
import Vue from "vue";
import state from "./state";
import getters from "./getters";
import mutations from "./mutations";
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex);
if (process.env.NODE_ENV === "development") {
	Vue.config.devtools = true;
	Vue.config.performance = true;
}

const store = new Vuex.Store({
	state,
	getters,
	mutations,
	//把所有数据缓存到本地-（默认是存储到localStorage里的）
	plugins: [
		createPersistedState({
			storage: window.localStorage
		})
	]
});

export default store;
